import hx.display.Spine;
import hx.display.FPS;
import hx.display.Image;
import hx.assets.Assets;
import hx.display.Stage;

class GameStage extends Stage {
	override function onStageInit() {
		super.onStageInit();
		// 代码开始的地方...
		var assets = new Assets();
		assets.loadSpineAtlas("assets/fx_saltCow2_skill.png", "assets/fx_saltCow2_skill.atlas");
		assets.loadString("assets/fx_saltCow2_skill.json");
		assets.loadSpineAtlas("assets/btn_mianfeifuli.png", "assets/btn_mianfeifuli.atlas");
		assets.loadString("assets/btn_mianfeifuli.json");
		assets.onComplete((a) -> {
			trace("Assets loaded");
			var spine = new Spine(assets.getSkeletonData("fx_saltCow2_skill"));
			this.addChild(spine);
			spine.x = stageWidth / 2;
			spine.y = stageHeight / 2 + 200;
			spine.play("idle");
			spine.skeleton.setSkinByName("blue");
			// btn_mianfeifuli
			var spine2 = new Spine(assets.getSkeletonData("btn_mianfeifuli"));
			this.addChild(spine2);
			spine2.x = stageWidth / 2 - 300;
			spine2.y = stageHeight / 2 - 200;
			spine2.play("daiji");
		});
		assets.start();

		var fps = new FPS();
		this.topView.addChild(fps);
	}
}
